<link rel="stylesheet" href="plugin/xl_editormd/editormd/css/editormd.min.css"/>
<style>
	.CodeMirror-placeholder { display: none; }
</style>
<script src="plugin/xl_editormd/editormd/editormd.min.js"></script>
<script>
    $(function () {
        // markdown format
        if (typeof jform !== undefined) {
            jform.find('[name="doctype"]').val(2);
        }

        // get message & remove default textarea
        const msgDef = $('#md-editor').parent().prev();
        const data = msgDef.children('#message').val();
        msgDef.remove();

        // load editor.md
        const editor = editormd('md-editor', {
            mode: 'markdown',
            name: 'message',
            markdown: data,
            placeholder: '请输入 Markdown 内容',
            htmlDecode: true,
            width: '100%',
//            	height : '100%',
            height: '300px',
            imageUpload: true,
            imageUploadURL: 'attach-create.htm',
            onload: function () {
                // 引入插件 执行监听方法
                editormd.loadPlugin('plugin/xl_editormd/editormd/plugins/image-handle-paste/image-handle-paste', function () {
                    editor.imagePaste();
                });
            },
            path: 'plugin/xl_editormd/editormd/lib/',
            toolbarIcons: function () {
                return [
                    'undo', 'redo', '|',
                    'bold', 'del', 'italic', 'quote', '|',
                    'list-ul', 'list-ol', 'hr', '|',
                    'link', 'reference-link', 'image', 'code', 'code-block', 'table', 'datetime', 'html-entities', 'pagebreak', '|', 
                    'watch', 'preview', 'fullscreen', 'help', 
                ];
            },
        });
    })
</script>
